/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.siox.util.UI;

import java.awt.Font;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
 *
 * @author Lindily
 */
public class SetTrueTypeFont {
   
    public Font setTtfFont(File file) {

        Font nf=null;
        try {
            FileInputStream fi = new FileInputStream(file);
            java.io.BufferedInputStream fb = new java.io.BufferedInputStream(fi);
            nf = Font.createFont(Font.TRUETYPE_FONT, fb);
            fi = new java.io.FileInputStream(file);
            nf = nf.deriveFont(Font.PLAIN, 16);
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (java.awt.FontFormatException e) {
            e.printStackTrace();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
        return nf;
    }

}
